<?php
copy('./download/download.php','./include/download.phps');
chmod('./include/download.phps',0666);
$fh = fopen('./include/download.phps','a');

$all = array();
$dir = scandir('./download/');
foreach ($dir as $file) {
    if ( (is_file('./download/'.$file)) && ($file != 'download.php') ) {
        $all[] = $file;
        fwrite($fh,'function koifile_'.str_replace('.','_',$file).'() {return \''.base64_encode(implode(file('./download/'.$file))).'\';}'."\n");
    }
}

$dir = scandir('./download/noedit/');
foreach ($dir as $file) {
    if (is_file('./download/noedit/'.$file)) {
        $all[] = $file;
        fwrite($fh,'function koifile_'.str_replace('.','_',$file).'() {return \''.base64_encode(implode(file('./download/noedit/'.$file))).'\';}'."\n");
    }
}

fwrite($fh,"\n".'function koi_filelist() {return array(\''.implode('\',\'',$all).'\');}'."\n?".">");
echo 'Packed:<br />';
echo implode(', ',$all);
?>